package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.Hospital;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HospitalIntroMapper;
import com.ruoyi.system.domain.HospitalIntro;
import com.ruoyi.system.service.IHospitalIntroService;

/**
 * 医院介绍Service业务层处理
 *
 * @author ruoyi
 * @date 2025-05-13
 */
@Service
public class HospitalIntroServiceImpl implements IHospitalIntroService {
    @Autowired
    private HospitalIntroMapper hospitalIntroMapper;

    /**
     * 查询医院介绍
     *
     * @param id 医院介绍主键
     * @return 医院介绍
     */
    @Override
    public HospitalIntro selectHospitalIntroById(Long id) {
        return hospitalIntroMapper.selectHospitalIntroById(id);
    }

    /**
     * 查询医院介绍列表
     *
     * @param hospitalIntro 医院介绍
     * @return 医院介绍
     */
    @Override
    public List<HospitalIntro> selectHospitalIntroList(HospitalIntro hospitalIntro) {
       List<HospitalIntro> list = hospitalIntroMapper.selectHospitalIntroList(hospitalIntro);
        for (HospitalIntro intro : list) {
          String hospitalName =  hospitalIntroMapper.selectHospitalName(intro.getHospitalId());
          intro.setHospitalName(hospitalName);
        }

        return list;
    }

    /**
     * 新增医院介绍
     *
     * @param hospitalIntro 医院介绍
     * @return 结果
     */
    @Override
    public int insertHospitalIntro(HospitalIntro hospitalIntro) {
        hospitalIntro.setCreateTime(DateUtils.getNowDate());
        return hospitalIntroMapper.insertHospitalIntro(hospitalIntro);
    }

    /**
     * 修改医院介绍
     *
     * @param hospitalIntro 医院介绍
     * @return 结果
     */
    @Override
    public int updateHospitalIntro(HospitalIntro hospitalIntro) {
        hospitalIntro.setUpdateTime(DateUtils.getNowDate());
        return hospitalIntroMapper.updateHospitalIntro(hospitalIntro);
    }

    /**
     * 批量删除医院介绍
     *
     * @param ids 需要删除的医院介绍主键
     * @return 结果
     */
    @Override
    public int deleteHospitalIntroByIds(Long[] ids) {
        return hospitalIntroMapper.deleteHospitalIntroByIds(ids);
    }

    /**
     * 删除医院介绍信息
     *
     * @param id 医院介绍主键
     * @return 结果
     */
    @Override
    public int deleteHospitalIntroById(Long id) {
        return hospitalIntroMapper.deleteHospitalIntroById(id);
    }

    @Override
    public List<Hospital> selectHospitalList() {
        return hospitalIntroMapper.selectHospitalList();
    }
}
